import delimited "$data/NLSY97/attendance_probs.csv", clear
gen sigma = .
replace sigma = 0.16666 if ability == "low"
replace sigma = 0.5 if ability == "medium"
replace sigma = 0.83333 if ability == "high"
drop ability

gen option = .
replace option = 1 if attendance == "community"
replace option = 2 if attendance == "public four year"
replace option = 3 if attendance == "private low quality"
replace option = 4 if attendance == "private high quality"
drop attendance


//start fitting some linear models!


reg prhs sigma if option==1



forval i = 1/4{
	reg prhs sigma if option == `i'
	local cons_hs_`i' = _b[_cons]
	local slope_hs_`i' = _b[sigma]
	
	reg prsomecoll sigma if option == `i'
	local cons_sc_`i' = _b[_cons]
	local slope_sc_`i' = _b[sigma]
	
	reg prcoll sigma if option == `i'
	local cons_coll_`i' = _b[_cons]
	local slope_coll_`i' = _b[sigma]
}


clear

set obs 12
gen option = .
gen outcome = .
gen intercept = .
gen slope = .

local counter = 0
local counter2 = 0

forval i = 1/4{
		local counter `++counter'
		replace intercept = `cons_hs_`i'' in `counter'
		replace slope = `slope_hs_`i'' in `counter'
		replace outcome = 1 in `counter'
		replace option = `i' in `counter'
		
		local counter `++counter'
		replace intercept = `cons_sc_`i'' in `counter'
		replace slope = `slope_sc_`i'' in `counter'
		replace outcome = 2 in `counter'
		replace option = `i' in `counter'
		
		local counter `++counter'
		replace intercept = `cons_coll_`i'' in `counter'
		replace slope = `slope_coll_`i'' in `counter'
		replace outcome = 3 in `counter'
		replace option = `i' in `counter'
		
		
}
export delimited "$dir/Model/utilities/grad_probs.csv", replace novarn
save "$temp/grad_probs", replace



//now make some graphs!
use "$temp/grad_probs", clear

forval y = 0/10{
	gen prob`y' = intercept + slope*(`y'/10)
	replace prob`y' = 0 if prob`y'<0
	replace prob`y' = 1 if prob`y'>1
}

reshape long prob, i(option outcome) j(ability)
replace ability = ability/10

//time for plots!

line prob ability if option == 1 & outcome == 1, ytitle("Outcome Probability") xtitle("Ability") ylabel(0(0.1)1.0, nogrid) xlabel(0(0.1)1.0, nogrid) || ///
line prob ability if option == 1 & outcome == 2 || ///
line prob ability if option == 1 & outcome == 3, legend(lab(1 "Dropout") lab(2 "Some College") lab(3 "College")) graphregion(color(white))
graph export "$output/grad_probs_comm.png", replace

line prob ability if option == 2 & outcome == 1, ytitle("Outcome Probability") xtitle("Ability") ylabel(0(0.1)1.0, nogrid) xlabel(0(0.1)1.0, nogrid) || ///
line prob ability if option == 2 & outcome == 2 || ///
line prob ability if option == 2 & outcome == 3, legend(lab(1 "Dropout") lab(2 "Some College") lab(3 "College")) graphregion(color(white))
graph export "$output/grad_probs_public.png", replace

line prob ability if option == 3 & outcome == 1, ytitle("Outcome Probability") xtitle("Ability") ylabel(0(0.1)1.0, nogrid) xlabel(0(0.1)1.0, nogrid) || ///
line prob ability if option == 3 & outcome == 2 || ///
line prob ability if option == 3 & outcome == 3, legend(lab(1 "Dropout") lab(2 "Some College") lab(3 "College")) graphregion(color(white))
graph export "$output/grad_probs_privlq.png", replace

line prob ability if option == 4 & outcome == 1, ytitle("Outcome Probability") xtitle("Ability") ylabel(0(0.1)1.0, nogrid) xlabel(0(0.1)1.0, nogrid) || ///
line prob ability if option == 4 & outcome == 2 || ///
line prob ability if option == 4 & outcome == 3, legend(lab(1 "Dropout") lab(2 "Some College") lab(3 "College")) graphregion(color(white))
graph export "$output/grad_probs_privhq.png", replace

graph close



//end of dofile

